package leetcode.code0168;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public String convertToTitle(int columnNumber) {
		StringBuffer sb = new StringBuffer();
		while (columnNumber > 0) {
			int mod = columnNumber % 26;
			columnNumber /= 26;
			if (mod != 0) {
				sb.insert(0, (char) (mod + 64));
			} else {
				sb.insert(0, 'Z');
				columnNumber -= 1;
			}
		}
		return sb.toString();
	}

	@Override
	public void debug1() {
		HelpDebug.compare("ZY", this.convertToTitle(701));

	}

	@Override
	public void debug2() {
		HelpDebug.compare("AB", this.convertToTitle(28));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		System.out.println('A' - 64);

	}

}
